/*
 * Copyright 2007 by ChinanetCenter Corporation.
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * ChinanetCenter Corporation ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with ChinanetCenter.
 * 
 */
package com.cnc.bas.common;

import javax.servlet.http.HttpServletRequest;

/**
 * IBatis查询及分页管理类。<br>
 * <p/>
 * 在使用IBatis进行分页查询时，可使用此类为参数，并返回相应查询结果及总记录数（如果需要）。<br>
 * <p/>
 * <b>特别说明：由于iBatis采用的查询分页技术不是数据库本身的分页技术，而是采用ResultSet的absolute定位技术，<br>
 * 需要把查询结果全部装入ResultSet再定位。如果查询结果较大（1万条记录以上)，效率会很低。<br>
 * 建议使用Hibernate的查询分页技术。
 * <p/>
 * 如果需要返回查询总记录数(countTotalSize = true)
 * </b>
 *
 * @author Longtop.com
 * @version 1.5
 */
public class SQueryInfo extends AbstractQueryInfo {

    //查询Sql Map语句id
    private String statementId;

    //查询参数值对象(可为Javabean,Map等)
    private Object paramValue;

    /**
     * 根据HttpServletRequest创建hql对象
     *
     * @param request 
     */
    public SQueryInfo(HttpServletRequest request) {
        super(request);
        statementId = null;
        paramValue = null;
    }

    public SQueryInfo() {
        super();
        statementId = null;
        paramValue = null;
    }
    /**
     * 设置iBatis执行查询语句Sql Map的statementId及执行查询总计数(如果需要返回查询总记录数)<br>
     * <p/>
     * 示例如下<br>
     * <pre>
     * //一、用普通Javabean作为参数查询：<br>
     * IwbFrameCodeType codeTypeObj = new IwbFrameCodeType();
     * codeTypeObj.setCodeType("0010");
     * codeTypeObj.setCodeTypeName("机构类型");
     * <p/>
     * sqlWrapper.setParameter("codeType.searchCodeType","codeType.countCodeTypeCount",codeTypeObj);
     * <p/>
     * //二、用Map作为参数查询：<br>
     * Map map = new HashMap();
     * map.put("codeType","0010");
     * map.put("codeTypeName","机构类型");
     * <p/>
     * sqlWrapper.setParameter("codeType.searchCodeType","codeType.countCodeTypeCount",map);
     * <p/>
     * //三、配置SQL Map文件
     * &lt;sqlMap namespace="codeType"&gt;
     * <p/>
     * &lt;typeAlias alias="IwbFrameCodeType" type="com.longtop.intelliwebframework.base.model.IwbFrameCodeType"/&gt;
     * <p/>
     * &lt;resultMap id="IwbFrameCodeTypeResult" class="com.longtop.intelliwebframework.base.model.IwbFrameCodeType"&gt;
     * &lt;result column="code_type" property="codeType" jdbcType="VARCHAR"/&gt;
     * &lt;result column="code_type_name" property="codeTypeName" jdbcType="VARCHAR"/&gt;
     * &lt;/resultMap&gt;
     * <p/>
     * &lt;!--以下定义查询语句--&gt;
     * &lt;select id="searchCodeType" resultMap="IwbFrameCodeTypeResult"  parameterClass="IwbFrameCodeType"&gt;
     * select code_type,code_type_name from iwb_frame_code_type
     * where code_type =#codeType# and code_type_name = #codeTypeName#
     * &lt;/select&gt;
     * <p/>
     * &lt;!--以下定义返回总记录数的查询语句--&gt;
     * &lt;select id="countCodeTypeCount" resultClass="int" parameterClass="IwbFrameCodeType"&gt;
     * select count(*) as result from iwb_frame_code_type
     * where code_type =#codeType# and code_type_name = #codeTypeName#
     * &lt;/select&gt;
     * <p/>
     * &lt;/sqlMap&gt;
     * </pre>
     *
     * @param statementId      调用iBatis的SqlMap文件的声明段名，规则名：SqlMap的namespace+"." + 该sqlMap文件某片段的id
     * @param paramValue       查询条件的值，可为JavaBean,Map对象。
     */
    public void setParameter(String statementId, Object paramValue) {
        this.statementId = statementId;
        this.paramValue = paramValue;
    }


    public String getStatementId() {
        return statementId;
    }

    public void setStatementId(String statementId) {
        this.statementId = statementId;
    }

    public Object getParamValue() {
        return paramValue;
    }

    public void setParamValue(Object paramValue) {
        this.paramValue = paramValue;
    }
}
